import { Router } from 'express';
import User from '../model/user.js';
import jwt from 'jsonwebtoken';
import { PUBLIC_KEY } from '../config.js';
import auth from '../utils/auth.js';
import db from '../model/index.js';

const router = Router();

router.get('/', auth, async function (req, res) {
  console.log('req', req);

  let user = await User.query().find(req.params.id);
  res.send(user);
});

router.post('/login', async (req, res) => {
  let token = jwt.sign({ id: 1 }, PUBLIC_KEY, { expiresIn: 60 * 60 * 24 });
  res.send(token);
});

export default router;
